﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PerpheralDevice.Units;

public class SwitchROMocker {

    private readonly MockEnum mfMockEnumID;
    public SwitchROMocker(MockEnum mockEnum) {
        this.mfMockEnumID = mockEnum;
    }

    public bool MockValue {
        get {
            return SwitchROMocker.GenValue(mfMockEnumID);
        }
    }

    public static bool GenValue(MockEnum mockEnum) {
        switch (mockEnum) {
            case MockEnum.Open:
                return true;
            case MockEnum.Shut:
                return false;
            case MockEnum.Random:
                if (new Random((int)DateTime.Now.Ticks).Next() > int.MaxValue / 2) {
                    return true;
                } else {
                    return false;
                }
        }

        return false;
    }
}

public enum MockEnum {
    /// <summary>
    /// 模拟 开值
    /// </summary>
    Open = 1,
    /// <summary>
    /// 模拟 关值
    /// </summary>
    Shut = 2,
    /// <summary>
    /// 模拟随机 开、关 值
    /// </summary>
    Random = 3
}
